import { Entity, Column, PrimaryGeneratedColumn, ManyToOne, JoinColumn } from 'typeorm'
import { OrderEntity } from './order.entity'

@Entity('order_score')
export class OrderScoreEntity {
  @PrimaryGeneratedColumn()
  id: number

  @ManyToOne(() => OrderEntity, (order) => order.id, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'order_id' }) // 外键关联订单ID
  order: OrderEntity

  @Column({ type: 'int', comment: '评分(1-5分)' })
  score: number

  @Column({ type: 'varchar', length: 500, nullable: true, comment: '评价内容' })
  comment?: string

  @Column({ type: 'varchar', length: 255, nullable: true, comment: '评价图片URL，多个用逗号分隔' })
  photo_url?: string

  @Column({ default: Math.floor(Date.now() / 1000), comment: '评价时间' })
  create_time: number
}